package com.queen.restaurant.dao;

import org.hibernate.Query;

import com.queen.restaurant.domain.CommentRestaurant;

public class CommentRestaurantDao extends BaseDao<CommentRestaurant>{

	//根据餐厅ID获取餐厅的评分
	public double getRestaurantAvgRank(String id){
		
		String hql = "SELECT avg(rank) FROM CommentRestaurant commentRestaurant where commentRestaurant.order.restaurant.id=:id";
		
		Query query = getSession().createQuery(hql);
		query.setString("id", id);
		
		return (Double)query.list().get(0);
	}
}
